package Rozetka.test;

import Rozetka.Pages.HomePage;
import Rozetka.Pages.RegistrationPage;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.util.Random;

public class AuthorizationPositive extends TestCondition {

    Random r = new Random();
    int number = r.nextInt(100000);

    @DataProvider(name = "PositiveRegistration")
    public Object[][] provideData1()
    {
        return new Object[][]         {
                { "Vitala" + number, "vit.rasdc" + number + "@gmail.com", "123456aaa" },
        };
    }

    @Test(dataProvider = "PositiveRegistration")
    public void positiveUserRegistration(String Name, String Email, String Password){
        HomePage home = new HomePage(driver);
        home.open();
        RegistrationPage registr = home.openRegistrationPage();
        registr.registrNewUser(Name, Email, Password);
        Assert.assertTrue(registr.isUserRegistred(Name));
    }

    @AfterMethod
    public void post() {
        HomePage home = new HomePage(driver);
        home.open();
        Assert.assertTrue(home.logOut());
    }

}
